﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace SimpleNotify.Service
{
    public class Logger
    {
        private string _filename;
        private readonly object fileLock = new object();

        public Logger(string filename)
        {
            _filename = filename;
        }

        internal void Write(string text)
        {
            string textToLog = DateTime.Now.ToString() + " | Service | " + text;                
            Console.WriteLine(textToLog);
            lock (fileLock)
            {
                File.AppendAllText(_filename, textToLog + Environment.NewLine);
            }
        }
    }
}